home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Programming / ARexxGuide / Extras / ARx_Help.rexx < prev    next >
OS/2 REXX Batch file  |  1994-03-23  |  4KB  |  152 lines

  1. /** $VER: ARX_Help.rexx 1.0 (06 Oct 1993)
  2.  ** by Robin Evans (based on getxref.ttx by David N. Junod)
  3.  **
  4.  ** Display the ARexxGuide page for the word on command line.
  5.  **
  6.  ** This can be used as a shell help-key macro with WShell.
  7.  ** Add the following (or something similar) to Config-FComp:
  8.  **
  9.  ** KEY 95 QUAL 8 NAME "CTRL-HELP"     FMT "*E[61]arx_help *N"
  10.  **
  11.  **  With this definition, a word can be typed on the shell. When
  12.  **  Ctrl-Help is pressed, the ARexxGuide node for that word will
  13.  **  be displayed.
  14.  **
  15.  ** Functions are (usually) recognized without the '()'
  16.  **
  17.  ** You may want to add the following lines to your S:user-startup file.
  18.  **
  19.  **   RXLIB amigaguide.library 0 -30
  20.  **
  21.  ** Be careful with that library, however. I've found that it interferes
  22.  ** in some cases with rexxarplib.library. If that happens, it can be
  23.  ** removed with this shell command:
  24.  **
  25.  **   RX "remlib('amigaguide.library')
  26.  **
  27.  **  THE AMIGAGUIDE/PATH ENVIRONMENTAL VARIABLE MUST INCLUDE THE DIRECTORY
  28.  **  WHERE ARx_Guide.xref IS LOCATED.
  29.  **/
  30.  
  31. signal on syntax
  32. signal on break_c
  33. signal on halt
  34. signal on failure
  35.  
  36.  
  37. arg LkUp
  38.  
  39.     if ~show('L','amigaguide.library') then
  40.         call addlib('amigaguide.library',-2,-30,0)
  41.    if ~show('L','rexxsupport.library') then
  42.        call addlib('rexxsupport.library',0,-30,0)
  43.  
  44.     XrefFile = 'ARx_Guide.xref'
  45.     if getxref('STATEF()') = 10 then
  46.         call loadxref(XrefFile)
  47.  
  48.     if open(.GtEnv, 'env:arexxguide/agcmd', R) then do
  49.         AGCmd = readln(.GtEnv)
  50.         call close .GtEnv
  51.     end
  52.     else
  53.     signal NoCmd
  54.     if abbrev(AGCmd, 'Multi') then
  55.        PrtOpt = ''
  56.     else
  57.        PrtOpt = 'portname ARX_GUIDE'
  58.  
  59.     if LkUp = '' then do
  60.         File = 'Arx_Index'
  61.         LkUp = 'ARx_NdxCont'
  62.     end
  63.     else do
  64.         File = ''
  65.         if getxref(LkUp) = 10 then do
  66.             if getxref(LkUp'()') ~= 10 then
  67.                 LkUp = LkUp'()'
  68.         end
  69.         if getxref(LkUp) = 10 then do
  70.             say 'Can''t find ARexxGuide reference to' LkUp'.'
  71.             options prompt 'View index? (y/N) '
  72.             pull resp
  73.             if abbrev(resp, 'Y') then do
  74.                 File = 'Arx_Index'
  75.                 LkUp = 'MAIN'
  76.             end
  77.             else exit 5
  78.         end
  79.     end
  80.    Cmd = ''
  81.  
  82.       /* See if our AG window is open */
  83.    if ~show('P','ARX_GUIDE') then do
  84.       if Cmd = '' then
  85.          Cmd = 'run' AGCmd File 'document' LkUp PrtOpt 'requester'
  86.  
  87.       address command cmd
  88.     end
  89.    else do
  90.  
  91.          /* What command do we use to show the node */
  92.        LinkCmd = "Link"
  93.         if File > '' then
  94.             LkUp = File'/'LkUp
  95.        address ARX_GUIDE LinkCmd LkUp
  96.        address ARX_GUIDE 'unzoomwindow'
  97.        address ARX_GUIDE 'windowtofront'
  98.     end
  99.  
  100. exit 0
  101.  
  102. XRefError:
  103.     ErrLine = SIGL
  104.     ErrMsg.0 = 5
  105.     ErrMsg.2 = 'Unable to load the cross-reference file ARx_Guide.xref'
  106.     if ~exists('env:amigaguide/path') then
  107.         ErrMsg.3 = 'Your environmental variable "amigaguide/path" is not set.'
  108.     else
  109.         ErrMsg.3 = '   Be sure to include that file''s directory in env:amigaguide/path.'
  110.     ErrMsg.4 = '   The .xref file may be put into the current directory or into'
  111.     ErrMsg.5 = '   any directory included in the amigaguide/path environmental variable.'
  112.     signal PutErrMsg
  113. NoCmd:
  114.     ErrLine = SIGL
  115.     ErrMsg.0 = 4
  116.     ErrMsg.2 = 'Can''t read environmental variable "env:arexxguide/AGcmd".'
  117.     ErrMsg.3 = '   That variable must hold the name of the command you use'
  118.     ErrMsg.4 = '   to show AmigaGuide files.'
  119.     signal PutErrMsg
  120. Syntax:
  121.     ErrLine = SIGL
  122.     ErrMsg.0 = 2
  123.     ErrMsg.2 = '   Syntax error #'rc ':' errortext(rc)
  124.     Signal PutErrMsg
  125. Failure:
  126.     ErrMsg.0 = 2
  127.     ErrMsg.2 = '   Command "'sourceline(SIGL)'" failed.'
  128.     ErrLine = SIGL
  129.     Signal PutErrMsg
  130. Halt:
  131. Break_C:
  132.     ErrMsg.0 = 2
  133.     ErrMsg.2 = '   Execution halted.'
  134.     ErrLine = SIGL
  135. PutErrMsg:
  136.     call trace b
  137.     ErrMsg.1 ='Sorry an enexpected error has occured in line' ErrLine'.'
  138.  
  139.     signal off syntax
  140.     signal off halt
  141.     signal off break_c
  142.     WinHi = 48 + ErrMsg.0 * 11
  143.     'SetStatusBar ARx_Help.ttx error.'
  144.     if open(.ErrWin, 'con:0/0/640/'WinHi'/Arx_Help Error/CLOSE') then do
  145.         do i = 1 to ErrMsg.0
  146.             call writeln(.ErrWin, ErrMsg.i)
  147.         end
  148.         call writech(.ErrWin, '0a'x'               Press <Enter>')
  149.         call readln(.ErrWin)
  150.     end
  151. exit 0
  152.